跳到主要内容

SetStyle

Sets the style to the current Range.

Syntax

expression.SetStyle(oStyle);

expression - A variable that represents a ApiRange class.

Parameters

NameRequired/OptionalData typeDefaultDescription
oStyleRequiredApiStyleThe style which must be applied to the text character.

Returns

ApiRange | null

Example

This example sets the style to the current Range.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("ONLYOFFICE Document Builder");
let range = doc.GetRange(0, 26);
let style = doc.GetStyle("Heading 2");
range.SetStyle(style);